﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OF.Security.Utils
{
    public class APIBaseResponse<T>
    {

        /// <summary>
        /// 请求结果
        /// </summary>
        public bool APIResult { get; set; }
        /// <summary>
        /// 错误信息，只有当APIResult为false时才有意思
        /// </summary>
        public string APIErrorMsg { get; set; }
        /// <summary>
        /// 请求成功时返回的数据
        /// </summary>
        public T Data { get; set; }

        public APIBaseResponse<T> Success(T data)
        {
            APIBaseResponse<T> result = new APIBaseResponse<T>
            {
                APIResult = true,
                APIErrorMsg = string.Empty,
                Data = data
            };
            return result;
        }
        public APIBaseResponse<T> Error(string errMsg)
        {
            APIBaseResponse<T> result = new APIBaseResponse<T>
            {
                APIResult = false,
                APIErrorMsg = errMsg
            };
            return result;
        }

    }
}
